<!DOCTYPE html>
<html><head ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录 - 开放实验室</title>
    
    <!-- Bootstrap core CSS -->
	<link href="../css/themes/default/easyui.css" rel="stylesheet" />
    <link href="../css/screen.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="../script/jquery.min.js"></script>
	<script src="../script/jquery.easyui.min.js"></script>
    <link href="../css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
    <script src="../script/jquery.cookie.js"></script>
   </head>
	<script type="text/javascript">
		function checkID()
		{
			function check()
			{
				var reg=/^[0-9]*$/;
				return !reg.test($("id").val());
			}
			if($("#id").val()=="")
			{
				$("#idMsg").html("×此项不能为空！");
				return false;
			}else
			{
				if(!check())
				{
					$("#idMsg").html("×格式不正确！");
					return false;
				}else
				{
					$("#idMsg").html("");
					return true;
				}
			}
		}
		function checkPw()
		{
			if($("#password").val()=="")
			{
				$("#pwMsg").html("×此项不能为空！");
				return false;
			}else
			{
				$("#pwMsg").html("");
				return true;
			}
		}
		function checkAll()
		{
			if(!checkID())
			{
				return false;
			}
			if(!checkPw())
			{
				return false;
			}
			return true;
		}
		function login()
		{
			if(checkAll())
			{
				var pars=
				{
					id:$("#id").val(),
					password:$("#password").val()
				}
				$.ajax({
					type:"post",
					contentType :'application/json;charset=utf-8',
					dataType:"json",  //数据格式设置为jsonp
					url : 'http://localhost:8080/libManager/user/login.do',
					data:JSON.stringify(pars), //额外的参数
					success:function (data) 
					{
						if(data.status==1)
						{
							$.cookie('uuid', data.data.uuid,{ path: '/' });
							$.cookie('user', JSON.stringify(data.data.user),{ path: '/' });
							$(location).attr('href', '../index.html');
						}else
						{
							$.messager.alert('系统提示', data.msg);
						}
					}
				});
			}else
			{
				$.messager.alert('系统提示', "输入项有空或格式不对！");
			}
		}
	</script>
  <body>
    <div class="openlab-masthead">
      <div class="container">
        <div class="logo col-sm-2">
          <img src="../img/logo.gif">
        </div>
        <div class="col-sm-7">
          <p class="openlab-slogan">
            我们曾经走过一样的岁月，也曾经为一样的事情流泪和欢笑，<br>
            我们宁愿忽视那些不同的想法和生活方式；<br>
            我们坚信，虽然我们的样子已经被社会打磨成千面，但是体温相似，情有共通。
          </p>
        </div>
          <div class="header-profile">
          </div>
      </div>
    </div>
    
    <div class="openlab-navbar">
      <div class="container">
        <ul class="openlab-nav">
          <li class="active"><a href=""><i class="glyphicon glyphicon-home"></i> 首页</a></li>
        </ul>
  </div>
    </div>
    <div class="container openlab-main">

      


<div class="row">
    <div class="col-sm-offset-4 col-sm-4">
        <form class="form-signin" role="form" method="post">
            <h2 class="form-heading">登录</h2>
            <hr>
                        <div class="form-group ">
                <label for="username">登录名</label>
                <input class="form-control" id="id" maxlength="128" placeholder="账号ID" type="text" value="" onchange="checkID()">
                <span class="help-block" style="color: red;" id="idMsg"></span>
            </div>
            <div class="form-group ">
                <label for="password">密码</label>
                <input class="form-control" id="password" maxlength="20" name="password" placeholder="Password" onchange="checkPw()" type="password" value="">
                <span class="help-block" style="color: red;" id="pwMsg"></span>
            </div>
            
            <button class="btn btn-lg btn-primary btn-block" type="button" onclick="login()">登录</button>
        </form>

        <div>
            <div>
                <a href="findPassword.html" class="forgot-password-link"><i class="icon-arrow-left"></i>忘记密码</a>
            </div>
        </div>
    </div>
    
</body></html>